package com.newbee.controller;

import com.newbee.model.MqCallbackBaseMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 模拟MQ/三方回调的接收控制器
 */
@RestController
@RequestMapping("/mock/mq/callback")
@Slf4j
public class MockMqCallbackController {

    /**
     * 接收本地HTTP回调（模拟MQ消息回调）
     */
    @PostMapping("/receive")
    public String receiveCallback(@RequestBody MqCallbackBaseMessage message) {
        // 1. 从回调消息中获取traceId，延续链路
        String traceId = message.getTraceId();
        log.info("收到模拟MQ回调，traceId={}，内容={}", traceId, message.getContent());

        return "回调成功，已处理消息: " + message.getContent();
    }
}
